package login;

import basemvp.BasePresenter;
import basemvp.MyCallBack;

/**
 * Created by Gao on 2019/1/31.
 */

public class MyPersenter extends BasePresenter<MyView> {

    public void getData(String param) {
        if (!isViewAttached()) {
            //如果没有View引用就不加载数据
            return;
        }
        getView().showLoading();
        MyModle.getNetData(param, new MyCallBack<String>() {
            @Override
            public void onSuccess(String data) {
                //调用view接口显示数据
                if (isViewAttached()) {
                    getView().showMsg(data);
                    getView().getData(data);
                }
            }

            @Override
            public void onFailure(String msg) {
                //调用view接口显示数据
                if (isViewAttached()) {
                    getView().showMsg(msg);
                    getView().getData(msg);
                }
            }

            @Override
            public void onComplete() {
                //调用view接口显示数据
                if (isViewAttached()) {
                    getView().finshLoading();
                }
            }
        });
    }
}
